home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip / MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf / Programming / Disabling_OS / TakeSystem2.s / TakeSystem2.s
Text File  |  1994-02-09  |  3KB  |  72 lines

  1. *******************************************************************
  2. * Short example of disabling of operating system for games, etc.  *
  3. * Disables system, changes the background colours a bit and then  *
  4. * enables system.                          *    
  5. * Disables the operating system by disabling ALL interrupts and   *
  6. * DMA. This method based on Bullfrog game code supplied with      *
  7. * Amiga Format Issues 39-43.                          *        
  8. * Uses VPOS wait loop described by Jolyon Ralph in the Machine    *
  9. * Code column in Amiga Computing 1990.                  *    
  10. * Written by James Margitich, 10th of April 1993.                 *
  11. *******************************************************************
  12.  
  13. INTENAR equ $dff01c
  14. DMACONR equ $dff002
  15.  
  16. INTENA equ $dff09a
  17. DMACON equ $dff096
  18. INTREQ equ $dff09c
  19.  
  20. VPOSR equ $dff004
  21. COLOUR0 equ $dff180
  22.  
  23.  
  24.     move.w  INTENAR,old_intena    ;save interrupt status
  25.     move.w  DMACONR,old_dmacon    ;save dma status
  26.     movem.l    d0-d7/a0-a6,-(sp)    ;save registers on the stack
  27.     move.w    #%0011111111111111,INTENA    ;disable interrupts
  28.     move.w    #%0000000111111111,DMACON    ;disable dma
  29.     move.w    #$7fff,INTREQ        ;take care of current interrupts    
  30. ;Here be where the body of the program begins. Feel free to delete it and 
  31. ;replace with your own code and rename this file accordingly.
  32.     move.l    #0,d0            ;Set loop counter to zero
  33.     move.l    #0,d1            ;Set colour counter to zero
  34.     move.w    #$3,d2            ;Set colour to $003
  35. loop
  36.     move.w    d2,COLOUR0        ;Set background colour
  37.     move.l    VPOSR,d3        ;get beam position
  38.     and.l    #%11111111100000000,d3    ;Only want vertical component
  39.     lsr.l    #8,d3            ;Move it to lower byte
  40.     cmp.w    #305,d3            ;Are we at the bottom of the screen?
  41.     bne.s    loop            ;If not, loop back now
  42.     cmp.l    #250,d0            ;Is loop counter at 250 (50vbi)?
  43.     bne    .samecolour
  44.     cmp.l    #6,d1            ;Is colour counter 6?
  45.     beq     .allfinished        ;If so, finish up.
  46.     add.w    #$2,d2            ;Increase colour no. by $002
  47.     move.l    #0,d0            ;reset loop counter
  48.     add.l    #1,d1            ;Increment colour counter    
  49.     bra.s    loop            ;Just reset counter, remember?
  50. .samecolour
  51.     add.l    #1,d0            ;Increment loop counter
  52. .fullframe
  53.     move.l    VPOSR,d3        ;get beam position
  54.     and.l    #%11111111100000000,d3    ;Only want vertical component
  55.     lsr.l    #8,d3            ;Move it to lower byte
  56.     cmp.w    #305,d3            ;Are we on next frame?
  57.     bge    .fullframe           ;If not, wait until we are
  58.     bra.s    loop            ;Loop back
  59. .allfinished
  60. ;Here be where the main program ends. 
  61.     move.w    old_intena,d0
  62.     or.w    #$8000,d0
  63.     move.w    d0,INTENA
  64.     move.w    old_dmacon,d0
  65.     or.w    #$8000,d0
  66.     move.w    d0,DMACON
  67.     movem.l    (sp)+,d0-d7/a0-a6    ;restore registers
  68.     rts         
  69.  
  70. old_intena    dc.w    0
  71. old_dmacon    dc.w    0
  72.